#! /usr/bin/env python
# -*- coding: utf8 -*-

import pygtk
pygtk.require('2.0')

import gtk
import sys
import gtk.gdk
import gnomeapplet

import gps_applet

gtk.gdk.threads_init()

def gps_factory(applet, iid):
    gps_applet.gps_applet(applet, iid)
    return True




if len(sys.argv) == 2 and sys.argv[1] == "window":
    main_window = gtk.Window(gtk.WINDOW_TOPLEVEL)
    main_window.set_title("Python Applet")
    main_window.connect("destroy", gtk.main_quit)

    app = gnomeapplet.Applet()
    gps_factory(app, None)
    app.reparent(main_window)
    main_window.show_all()
    
    gtk.main()
    sys.exit()
else:
    gnomeapplet.bonobo_factory("OAFIID:PythonGpsAppletFactory",
                               gnomeapplet.Applet.__gtype__, 
                               "Shows your current position", "1.0",
                               gps_factory)
